package com.wtc.exception;

/**
 * @author 马可
 * @version 1.0
 * 异常作业
 * 2023/5/14
 * IntelliJ IDEA
 */
public class Homework01 {
    public static void main(String[] args) {
        try {
            if (args.length != 2) {
                throw new ArrayIndexOutOfBoundsException("参数个数不正确");
            }
            int a = Integer.parseInt(args[0]);
            int b = Integer.parseInt(args[1]);
            double c = cal(a, b);
            System.out.println("计算结果：" + c);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println(e.getMessage());
        } catch (NumberFormatException e) {
            System.out.println("需要输入整数");
        } catch (ArithmeticException e) {
            System.out.println("除数错误");
        }
    }
    public static double cal(int a, int b) {
        return a / b;
    }
}
